/*
 * @Description:login页saga
 * @Version: P0600_V1.1
 * @Author: chenm
 * @Date: 2020-09-13 00:17:28
 */
import { takeEvery, put } from "redux-saga/effects";
import axios from "axios";

import { GET_INIT_LIST } from "./actionTypes";
import { initListAction } from "./actionCreators";

function* getInitList() {
  const {
    data: { result },
  } = yield axios.get("/gold/shgold?key=b429ba39d14a30326c2ab6d985e48ee9");
  const action = initListAction(result);
  yield put(action);
}

function* loginSaga() {
  //捕获GET_INIT_LIST的dispatch，然后用getInitList进行业务处理
  yield takeEvery(GET_INIT_LIST, getInitList);
}

export default loginSaga;
